﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Experimental.GlobalIllumination.LightDataGI
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Experimental.GlobalIllumination
{
  /// <summary>
  ///   <para>The interop structure to pass light information to the light baking backends. There are helper structures for Directional, Point, Spot and Rectangle lights to correctly initialize this structure.</para>
  /// </summary>
  [UsedByNativeCode]
  public struct LightDataGI
  {
    /// <summary>
    ///   <para>The light's instanceID.</para>
    /// </summary>
    public int instanceID;
    /// <summary>
    ///   <para>The cookie texture's instance id projected by the light.</para>
    /// </summary>
    public int cookieID;
    /// <summary>
    ///   <para>The uniform scale factor for downscaling cookies during lightmapping. Can be used as an optimization when full resolution cookies are not needed for indirect lighting.</para>
    /// </summary>
    public float cookieScale;
    /// <summary>
    ///   <para>The color of the light.</para>
    /// </summary>
    public LinearColor color;
    /// <summary>
    ///   <para>The indirect color of the light.</para>
    /// </summary>
    public LinearColor indirectColor;
    /// <summary>
    ///   <para>The orientation of the light.</para>
    /// </summary>
    public Quaternion orientation;
    /// <summary>
    ///   <para>The position of the light.</para>
    /// </summary>
    public Vector3 position;
    /// <summary>
    ///   <para>The range of the light. Unused for directional lights.</para>
    /// </summary>
    public float range;
    /// <summary>
    ///   <para>The cone angle for spot lights.</para>
    /// </summary>
    public float coneAngle;
    /// <summary>
    ///   <para>The inner cone angle for spot lights.</para>
    /// </summary>
    public float innerConeAngle;
    /// <summary>
    ///   <para>The light's sphere radius for point and spot lights, or the width for rectangle lights.</para>
    /// </summary>
    public float shape0;
    /// <summary>
    ///   <para>The height for rectangle lights.</para>
    /// </summary>
    public float shape1;
    /// <summary>
    ///   <para>The type of the light.</para>
    /// </summary>
    public LightType type;
    /// <summary>
    ///   <para>The lightmap mode for the light.</para>
    /// </summary>
    public LightMode mode;
    /// <summary>
    ///   <para>Set to 1 for shadow casting lights, 0 otherwise.</para>
    /// </summary>
    public byte shadow;
    /// <summary>
    ///   <para>The falloff model to use for baking point and spot lights.</para>
    /// </summary>
    public FalloffType falloff;

    public void Init(ref DirectionalLight light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = 0.0f;
      this.coneAngle = cookie.sizes.x;
      this.innerConeAngle = cookie.sizes.y;
      this.shape0 = light.penumbraWidthRadian;
      this.shape1 = 0.0f;
      this.type = LightType.Directional;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = FalloffType.Undefined;
    }

    public void Init(ref PointLight light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = 0.0f;
      this.innerConeAngle = 0.0f;
      this.shape0 = light.sphereRadius;
      this.shape1 = 0.0f;
      this.type = LightType.Point;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = light.falloff;
    }

    public void Init(ref SpotLight light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = light.coneAngle;
      this.innerConeAngle = light.innerConeAngle;
      this.shape0 = light.sphereRadius;
      this.shape1 = (float) light.angularFalloff;
      this.type = LightType.Spot;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = light.falloff;
    }

    public void Init(ref RectangleLight light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = 0.0f;
      this.innerConeAngle = 0.0f;
      this.shape0 = light.width;
      this.shape1 = light.height;
      this.type = LightType.Rectangle;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = light.falloff;
    }

    public void Init(ref DiscLight light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = 0.0f;
      this.innerConeAngle = 0.0f;
      this.shape0 = light.radius;
      this.shape1 = 0.0f;
      this.type = LightType.Disc;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = light.falloff;
    }

    public void Init(ref SpotLightBoxShape light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = 0.0f;
      this.innerConeAngle = 0.0f;
      this.shape0 = light.width;
      this.shape1 = light.height;
      this.type = LightType.SpotBoxShape;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = FalloffType.Undefined;
    }

    public void Init(ref SpotLightPyramidShape light, ref Cookie cookie)
    {
      this.instanceID = light.instanceID;
      this.cookieID = cookie.instanceID;
      this.cookieScale = cookie.scale;
      this.color = light.color;
      this.indirectColor = light.indirectColor;
      this.orientation = light.orientation;
      this.position = light.position;
      this.range = light.range;
      this.coneAngle = light.angle;
      this.innerConeAngle = 0.0f;
      this.shape0 = light.aspectRatio;
      this.shape1 = 0.0f;
      this.type = LightType.SpotPyramidShape;
      this.mode = light.mode;
      this.shadow = light.shadow ? (byte) 1 : (byte) 0;
      this.falloff = light.falloff;
    }

    public void Init(ref DirectionalLight light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref PointLight light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref SpotLight light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref RectangleLight light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref DiscLight light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref SpotLightBoxShape light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    public void Init(ref SpotLightPyramidShape light)
    {
      Cookie cookie = Cookie.Defaults();
      this.Init(ref light, ref cookie);
    }

    /// <summary>
    ///   <para>Initialize a light so that the baking backends ignore it.</para>
    /// </summary>
    /// <param name="lightInstanceID"></param>
    public void InitNoBake(int lightInstanceID)
    {
      this.instanceID = lightInstanceID;
      this.mode = LightMode.Unknown;
    }
  }
}
